package leetcode.剑指offer.后40;

import org.junit.Test;

/**
 * @author :songyaozhang
 * @date :Created 2021/7/31 16:48
 * @description :https://leetcode-cn.com/problems/di-yi-ge-zhi-chu-xian-yi-ci-de-zi-fu-lcof/
 */
public class 剑指_50_第一个只出现一次的字符 {
    @Test
    public void test() {
        Solution solution = new Solution();

    }

    class Solution {
        public char firstUniqChar(String s) {
            int[] count = new int[26];
            for (int i = 0; i < s.length(); i++) {
                count[s.charAt(i) - 'a']++;
            }
            for (int i = 0; i < s.length(); i++) {
                char ch = s.charAt(i);
                if (count[ch - 'a'] == 1) return ch;
            }
            return ' ';
        }
    }


}
